﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DevExpress.XtraReports.Web;
using DevExpress.XtraReports;

public partial class WebUserControl_ControlReportBaoCaoDoiChieuTonKhoThucTe : System.Web.UI.UserControl
{
    SqlConnection con;
    string str = BCDataCenter.Configuration.CurrentConnectionString;
    DataTable dt;
    SqlDataAdapter da;
    MethodClassCommon common;
    protected void Page_Load(object sender, EventArgs e)
    {
      bindReport();
    }
    void bindReport()
    {
        try
        {
            common = new MethodClassCommon();
            con = new SqlConnection(str);
            ReportBaoCaoDoiChieuTonKhoThucTe rp = new ReportBaoCaoDoiChieuTonKhoThucTe();
            da = new SqlDataAdapter("BAOCAO_DOICHIEU_TONKHO_THUCTE", con);
            da.SelectCommand.CommandType = CommandType.StoredProcedure;
            da.SelectCommand.Parameters.Add(new SqlParameter("@TableName", Session["table"].ToString()));
            da.SelectCommand.Parameters.Add(new SqlParameter("@iradate", Session["iradate"].ToString()));
            da.SelectCommand.Parameters.Add(new SqlParameter("@location", Session["location"].ToString()));
            da.SelectCommand.Parameters.Add(new SqlParameter("@sitecode", Session["Sitecode"].ToString()));
           
            dt = new DataTable();
            da.Fill(dt);
            rp.Parameters["soluongtong"].Value = common.GetDataDepend("GET_TONGSO_IRAYYYY", "TableName", Session["table"].ToString(), "iradate", Session["iradate"].ToString(), "location", Session["location"].ToString(), "sitecode", Session["Sitecode"].ToString());
            rp.Parameters["soluongdung"].Value = common.GetDataDepend("GET_TONGSO_IRAYYYY_TRUE", "TableName", Session["table"].ToString(), "iradate", Session["iradate"].ToString(), "location", Session["location"].ToString(), "sitecode", Session["Sitecode"].ToString());
            rp.Parameters["iradate"].Value = Session["iradate"].ToString();
            rp.Parameters["location"].Value = Session["location"].ToString();
            rp.DataSource = dt;
            ReportViewer1.Report = rp;
            ReportViewer1.DataBind();
        }
        catch(Exception ex)
        {
            uscMsgBox1.AddMessage(ex.Message, uscMsgBox.enmMessageType.Error);
        }
    }
}
